//
//  UINavigationBar+Extenstion.swift
//  微博
//
//  Created by xm on 2018/3/19.
//  Copyright © 2018年 xm. All rights reserved.
//

import Foundation

class UINavigationBarExt:UINavigationBar{
    
    override func layoutSubviews() {
         super.layoutSubviews()
        
        //注意导航栏及状态栏高度适配(适配IOS 11)
        frame = CGRect(x: 0, y: 0, width: frame.width, height: frame.height)
        for view in subviews {
            let viewbg = subviews[0];//_UIBarBackground
            let viewcon = subviews[2];//_UINavigationBarContentView
            print(view);
            if(view == viewbg){
                view.frame = bounds;
            }else if(view == viewcon){
                var frame = view.frame;
                frame.origin.y = 20;
                frame.size.height = self.bounds.size.height - frame.origin.y;
                view.frame = frame;
            }
        }  
        /*
        for view in subviews {
            if(NSStringFromClass(view.classForCoder).contains("Background")) {
                view.frame = self.bounds;
            }else if (NSStringFromClass(view.classForCoder).contains("ContentView")) {
                var frame = view.frame;
                frame.origin.y = 20;
                frame.size.height = self.bounds.size.height - frame.origin.y;
                view.frame = frame;
            }
        }*/
    }
    
}
